Skip to content

feat(queue): backend queue state machine replacing frontend shuffle, navigation, and play-next logic#42

Merged
pythoninthegrass merged 4 commits into
mainfrom
pythoninthegrass/queue-state-machine
Apr 13, 2026
Merged

feat(queue): backend queue state machine replacing frontend shuffle, navigation, and play-next logic#42
pythoninthegrass merged 4 commits into
mainfrom
pythoninthegrass/queue-state-machine

Conversation

@pythoninthegrass
Copy link
Copy Markdown
Collaborator

@pythoninthegrass pythoninthegrass commented Apr 13, 2026

Summary

  • Move ~500 lines of queue state machine logic (shuffle, navigation, play-next pinning, history, integrity) from frontend JS to Rust backend
  • Frontend queue store becomes a thin reactive layer: call backend commands, apply returned state snapshots
  • Add 6 new Tauri commands: queue_add_play_next, queue_play_next_track, queue_play_previous_track, queue_skip_next, queue_skip_previous, queue_check_integrity
  • Extend queue_state DB table with play_next_offset, play_history_json, play_next_track_ids_json, repeat_one_pending columns
  • 773 Rust tests pass (69+ new), 444 frontend Vitest tests pass

Test plan

  • cargo nextest run -p mt-tauri — 773 tests pass
  • npx vitest run — 444 tests pass
  • Manual: verify shuffle/unshuffle preserves all tracks and current track at index 0
  • Manual: verify repeat-one replays track then advances
  • Manual: verify play-next inserts after current track with correct offset
  • Manual: verify previous track uses history stack

Closes TASK-328

🤖 Generated with Claude Code

pythoninthegrass and others added 4 commits April 13, 2026 12:19
…navigation, and play-next logic

Move ~500 lines of queue state machine from JS frontend to Rust backend.
Frontend queue store becomes a thin reactive layer calling backend commands
and applying returned state snapshots.

Backend:
- Extend queue_state table with play_next_offset, play_history_json,
  play_next_track_ids_json, repeat_one_pending columns
- Add toggle_shuffle (Fisher-Yates with play-next pinning),
  add_play_next (move semantics + offset tracking),
  advance_to_next/previous (repeat-one two-phase, loop modes, history),
  skip_to_next/previous (override repeat-one), check_integrity
- Register 6 new Tauri commands, enhance queue_set_shuffle to return
  QueueStateSnapshot
- 773 Rust tests pass

Frontend:
- Remove _shuffleItems, _reshuffleForLoopRestart, _originalOrder,
  _playHistory, _playNextTrackIds, _playNextOffset, _repeatOnePending,
  _syncQueueToBackend, _validateQueueIntegrity
- Add _applySnapshot and _applyNavigationResult
- Update queue-builder and queue.props tests for backend-delegated pattern
- 444 Vitest tests pass

Closes TASK-328

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove unnecessary async from _applyNavigationResult (no await inside).
Prefix unused fromNavigation parameter with underscore.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
toggleShuffle now sets this.shuffle before the backend call (like
cycleLoop does for loop mode), reverting on failure. Add aria-pressed
to the shuffle button so the E2E accessibility test detects state change.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@pythoninthegrass pythoninthegrass merged commit fe613b5 into main Apr 13, 2026
9 checks passed
@pythoninthegrass pythoninthegrass deleted the pythoninthegrass/queue-state-machine branch April 13, 2026 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant